package service;

import java.sql.SQLException;
import java.util.ArrayList;

import model.Status;
import dao.StatusDao;

public class StatusService extends GenericService{

	public StatusService() {
		super();
	}
	public ArrayList<Status> select(Status status, int paginaAtual) {
		int limit=this.getLimite();
		int inicio=(paginaAtual*limit)-limit;
		if (paginaAtual==0){//se pagina igual a zero retorna todos
			limit=0;
			inicio=0;
		}
		ArrayList<Status> statuss = null;
		try {
			StatusDao statusDao = new StatusDao();
			statuss=statusDao.getStatuss(status, limit, inicio);
			setCount(new StatusDao().countGetStatuss(status));
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return statuss;
	}
	
	public Status select(Status status) {
		ArrayList<Status> statuss = null;
		StatusDao statusDao = new StatusDao();
		try {
			statuss=statusDao.getStatuss(status, 0, 0);
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		Status status2= null;
		if (statuss!=null)
			status2 = statuss.get(0);
		return status2;
	}
	

}
